package org.superheroes.net.stream;

import java.io.FileInputStream;

/**
 * 
 * @author Jeffrey Goudzwaard
 * @author Davin Terrizzi
 * @version 1.0
 *
 */
public class VideoStream
{
	private FileInputStream fis = null;
	
	public VideoStream( String filename ) throws Exception
	{
		fis = new FileInputStream( "/data/" + filename );
	}
	
	/**
	 * returns the next frame number based on the given byte array
	 * 
	 * @param frame
	 * @return
	 * @throws Exception
	 */
	public int getNextFrame( byte[] frame ) throws Exception
	{
		int length = 0;
		
		String lengthString;
		byte[] frameLength = new byte[ 5 ];
		
		fis.read( frameLength, 0, 5 );
		
		lengthString = new String( frameLength );
		length = Integer.parseInt( lengthString );
		
		return fis.read( frame, 0, length );
	}
}
